export function formatDate(date: string | Date){
    if (! (date instanceof Date)){
      date = new Date(date);
    }
    let ms = (+new Date() - date.getTime())/1000;
    if (ms === 0){
      return '刚刚'
    }else if (ms < 60){
      return `${Math.floor(ms)}秒`
    }else if(ms < 60*60){
      return `${Math.floor(ms/60)}分钟`
    }else if(ms < 60*60*24){
      return `${Math.floor(ms/60/60)}小时`
    }else if(ms < 60*60*24*30){
      return `${Math.floor(ms/60/60/24)}天`
    }else if(ms < 60*60*24*30*12){
      return `${Math.floor(ms/60/60/24/30)}月`
    }else{
      return `${Math.floor(ms/60/60/24/30/12)}年`
    }
  }
  